package lee.android.factory;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;

public class ImageFactory {
	
	public static Bitmap getBitmap(String filePathImg, int width, int height) {
		//get original image
		Bitmap bitmap = BitmapFactory.decodeFile(filePathImg);
		//resize image
		int widthOrg = bitmap.getWidth();
	    int heightOrg = bitmap.getHeight();
	    float scaleWidth = ((float) width) / widthOrg;
	    float scaleHeight = ((float) height) / heightOrg;
	    Matrix matrix = new Matrix();
	    matrix.postScale(scaleWidth, scaleHeight);
	    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, widthOrg, heightOrg, matrix, false);
	    return resizedBitmap;
	}
}
